﻿using System.Web.Mvc;
using System.Web.Routing;

namespace Admin.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        /// <summary>
        /// 程序启动之前执行的方法
        /// </summary>
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }

        /// <summary>
        /// 注册路由
        /// </summary>
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{Action}/{id}", // URL with parameters
                new { controller = "Auth", action = "Login", id = UrlParameter.Optional } // Parameter defaults
            ).DataTokens.Add("area", "Account");
        }
    }
}
